<template>
  <el-dialog v-model="dialogVisible" title="设置分段价格" width="75%">
    <div class="dialog-top">
      <h3>
        {{ props.currentRow.dayOfWeek }}
      </h3>
      <span>开放时间：{{ props.currentRow.startTime }}-{{
        props.currentRow.endTime
      }}</span>
      <span>单位时间：60分钟</span>
    </div>
    <el-row :gutter="16">
      <el-col :span="6"><strong>时间段</strong></el-col>
      <el-col :span="9"><strong>价格</strong></el-col>
    </el-row>
    <el-row class="mb10 mt10 price-row" :gutter="16" v-for="(item, index) in props.currentRow.priceData" :key="index">
      <el-col :span="6">
        <el-time-select v-model="item.startTime" :max-time="item.endTime" :clearable="false"
          start="08:00" step="01:00" end="23:00" disabled />
        -
        <el-time-select v-model="item.endTime" :min-time="item.startTime" :clearable="false"
          start="08:00" step="01:00" end="23:00" disabled />
      </el-col>
      <el-col :span="9" class="flex-row">
        <el-input v-model="item.fullPrice" class="price-h">
          <template #append>元/小时</template>
        </el-input>
      </el-col>
    </el-row>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleSubmit">确认</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref } from "vue";

let dialogVisible = ref(false);
const props = defineProps<{
  currentIndex: number;
  currentRow: any;
  changePriceRange: Function;
}>();

const handleSubmit = () => {
  props.changePriceRange(props.currentIndex, props.currentRow);
  dialogVisible.value = false;
};

defineExpose({
  dialogVisible,
});
</script>


<style lang="scss" scoped>
.flex-row {
  display: flex;
  align-items: center;
}

.dialog-top {
  display: flex;
  align-items: center;
  margin-bottom: 15px;

  span {
    margin-left: 30px;
  }
}

.price-h {
  width: 150px;
}

.price-row {
  ::v-deep(.el-select) {
    width: 105px !important;
  }
}
</style>